from influxdb import InfluxDBClient
import logging as log

class InfluxDB:
    def init_app(self, app):
        host = app.config['INFLUXDB_HOST']
        port = app.config['INFLUXDB_PORT']
        user_name = app.config['INFLUXDB_USERNAME']
        password = app.config['INFLUXDB_PASSWORD']
        database = app.config['INFLUXDB_DATABASE']
        log.info("influxdb config:{},{},{},{},{}".format(host,port,user_name,password,database))
        self.client = InfluxDBClient(host=host, port=port, username=user_name, password=password, database=database)

    def get_client(self):
        return self.client